package com.skivingcloud.report.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.skivingcloud.report.entity.ReportSheetPdfPrintSetting;
import com.skivingcloud.report.mapper.ReportSheetPdfPrintSettingMapper;
import com.skivingcloud.report.service.ReportSheetPdfPrintSettingService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.skivingcloud.common.utils.PageParameter;

/**
 * pdf/打印设置表 服务层实现。
 *
 * @author skivingcloud
 * @since 2024-11-07
 */
@Service
public class ReportSheetPdfPrintSettingServiceImpl extends ServiceImpl<ReportSheetPdfPrintSettingMapper, ReportSheetPdfPrintSetting> implements ReportSheetPdfPrintSettingService {

    /**
     * 分页查询pdf/打印设置表
     *
     * @param parameter 查询参数
     * @return 分页查询结果
     */
    @Override
    public Page<ReportSheetPdfPrintSetting> queryByPage(PageParameter<ReportSheetPdfPrintSetting> parameter){
        Page<ReportSheetPdfPrintSetting> page = new Page<>(parameter.getPage(), parameter.getPageSize());
        QueryWrapper queryWrapper = QueryWrapper.create();
        if (parameter.getParam() != null) {
            //查询条件
            if (StringUtils.isNoneBlank(parameter.getParam().getId())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getId).like(parameter.getParam().getId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getTplId())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getTplId).like(parameter.getParam().getTplId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getTplSheetId())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getTplSheetId).like(parameter.getParam().getTplSheetId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getPageType())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getPageType).like(parameter.getParam().getPageType());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getPageLayout())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getPageLayout).like(parameter.getParam().getPageLayout());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getPageHeaderShow())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getPageHeaderShow).like(parameter.getParam().getPageHeaderShow());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getPageHeaderContent())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getPageHeaderContent).like(parameter.getParam().getPageHeaderContent());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getPageHeaderPosition())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getPageHeaderPosition).like(parameter.getParam().getPageHeaderPosition());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getWaterMarkShow())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getWaterMarkShow).like(parameter.getParam().getWaterMarkShow());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getWaterMarkType())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getWaterMarkType).like(parameter.getParam().getWaterMarkType());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getWaterMarkContent())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getWaterMarkContent).like(parameter.getParam().getWaterMarkContent());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getWaterMarkImg())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getWaterMarkImg).like(parameter.getParam().getWaterMarkImg());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getPageShow())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getPageShow).like(parameter.getParam().getPageShow());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getPagePosition())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getPagePosition).like(parameter.getParam().getPagePosition());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getCreator())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getCreator).like(parameter.getParam().getCreator());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getUpdater())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getUpdater).like(parameter.getParam().getUpdater());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDelFlag())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getDelFlag).like(parameter.getParam().getDelFlag());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getHorizontalPage())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getHorizontalPage).like(parameter.getParam().getHorizontalPage());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getHorizontalPageColumn())) {
                queryWrapper.and(ReportSheetPdfPrintSetting::getHorizontalPageColumn).like(parameter.getParam().getHorizontalPageColumn());
            }
        }
        return this.page(page, queryWrapper);
    }
}
